package demo.exception;

import java.util.Scanner;

public class Login {
    private static String userName = "admin";
    private static String passWord = "123456";

    public String getUserName() {
        return userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public static void LogInfo () throws UserNameErrorException,PassWordErrorException {
        Scanner sc = new Scanner(System.in);
        String inputUserName = sc.nextLine();
        String inputPassWord = sc.nextLine();

        if(!inputUserName.equals(userName)) {
            throw new UserNameErrorException("用户名错误！");
        }

        if(!inputPassWord.equals(passWord)) {
            throw  new PassWordErrorException("密码错误!");
        }

        System.out.println("登陆成功！");
    }

    public static void main(String[] args) {
        try {
            LogInfo();
        } catch (UserNameErrorException e) {
            e.printStackTrace();
        } catch (PassWordErrorException e) {
            e.printStackTrace();
        }

        System.out.println("程序结束");
    }
}
